﻿package mortal.game.view.ranking.renderer
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.GCatogeryList.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.palyer.util.*;
    import mortal.mvc.core.*;

    public class RankingCategoryHead extends CatogeryListHeadBase
    {
        private var _expandBtn:GLoadingButton;
        private var _txtExpandTitle:GTextFiled;
        private var _txtUnExpandTitle:GTextFiled;
        private var _selectBg:ScaleBitmap;
        private var _btnImg:GImageBitmap;
        private var _data:Object;
        private var _imgName:String;
        public static var currSelHead:RankingCategoryHead;

        public function RankingCategoryHead()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this._btnImg = UIFactory.gImageBitmap("", 0, 0, this);
            this._expandBtn = UIFactory.gLoadingButton("", 0, 0, 163, 44, this);
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.align = TextFormatAlign.CENTER;
            _loc_1.size = 14;
            _loc_1.color = 16707564;
            this._txtExpandTitle = UIFactory.gTextField("", 0, -2, 180, 22, this, _loc_1);
            _loc_1 = GlobalStyle.textFormatPutong;
            _loc_1.align = TextFormatAlign.CENTER;
            this._txtUnExpandTitle = UIFactory.gTextField("", 0, 1, 180, 22, this, _loc_1);
            this._selectBg = UIFactory.bg(-2, -2, 167, 48, this, ImagesConst.selectFilter2);
            this._selectBg.visible = false;
            this._txtExpandTitle.mouseEnabled = false;
            this._txtUnExpandTitle.mouseEnabled = false;
            this._txtExpandTitle.visible = false;
            this.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            return;
        }// end function

        override public function expand() : void
        {
            this._expandBtn.enabled = false;
            this._expandBtn.mouseEnabled = true;
            super.isExpanding = true;
            this.mouseEnabled = true;
            this.mouseChildren = true;
            this._txtExpandTitle.visible = true;
            this._txtUnExpandTitle.visible = false;
            return;
        }// end function

        override public function updateData(param1:Object) : void
        {
            this._data = param1;
            var _loc_2:* = int(this._data.name);
            switch(_loc_2)
            {
                case EToplistType._EToplistTypePlayerOverview:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_First_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypePlayerCombat:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Combat_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypePlayerLevel:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Level_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypeFashion:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Fashion_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypeWeapon:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Artifact_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypeWing:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Wing_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypeMountRank:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Mount_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypePetGrowth:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Pet_UpSkin;
                    break;
                }
                case EToplistType._EToplistTypeGuildCombat:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Guild_UpSkin;
                    break;
                }
                case -1:
                {
                    this._btnImg.imgUrl = ImagesConst.RankingCategory_Other_UpSkin;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._imgName = this._btnImg.imgUrl.substring(0, this._btnImg.imgUrl.length - 10);
            return;
        }// end function

        override public function setSize(param1:Number, param2:Number) : void
        {
            this._txtExpandTitle.width = param1;
            this._txtUnExpandTitle.width = param1;
            this._expandBtn.setSize(param1, param2);
            return;
        }// end function

        override public function unexpand() : void
        {
            super.isExpanding = false;
            this._expandBtn.enabled = true;
            this._txtExpandTitle.visible = false;
            this._txtUnExpandTitle.visible = true;
            return;
        }// end function

        override public function set dataProvider(param1:DataProvider) : void
        {
            super.dataProvider = param1;
            this._txtUnExpandTitle.text = this._txtExpandTitle.text;
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_3:int = 0;
            var _loc_4:String = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            var _loc_2:* = Cache.instance.role.entityInfo.level;
            var _loc_5:* = int(this._data.name);
            switch(_loc_5)
            {
                case EToplistType._EToplistTypeFashion:
                {
                    _loc_3 = GameConst.ClothOpenLevel;
                    _loc_4 = FashionUtil.getFashionNameByType(EAdvanceComponentType._EAdvanceComponentTypeClothes);
                    break;
                }
                case EToplistType._EToplistTypeWing:
                {
                    _loc_3 = GameConst.WingOpenLevel;
                    _loc_4 = FashionUtil.getFashionNameByType(EAdvanceComponentType._EAdvanceComponentTypeWing);
                    break;
                }
                case EToplistType._EToplistTypeWeapon:
                {
                    _loc_3 = GameConst.ArtifactOpenLevel;
                    _loc_4 = FashionUtil.getFashionNameByType(EAdvanceComponentType._EAdvanceComponentTypeWeapon);
                    break;
                }
                default:
                {
                    break;
                }
            }
            if (_loc_2 < _loc_3)
            {
                MsgManager.showRollTipsMsg(_loc_4 + _loc_3 + Language.getString(41320));
                _loc_6 = {};
                _loc_6.type = 404;
                Dispatcher.dispatchEvent(new DataEvent(EventName.RankingGetRankList, _loc_6));
                return;
            }
            if (int(this._data.name) == EToplistType._EToplistTypePlayerOverview)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.RankingGetFirstInfo));
            }
            else if (int(this._data.name) != -1)
            {
                _loc_7 = {};
                _loc_7.type = int(this._data.name);
                Dispatcher.dispatchEvent(new DataEvent(EventName.RankingGetRankList, _loc_7));
            }
            return;
        }// end function

        override public function set isSelected(param1:Boolean) : void
        {
            this._selectBg.visible = param1;
            this._btnImg.imgUrl = param1 ? (this._imgName + "DownSkin") : (this._imgName + "UpSkin");
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._expandBtn.dispose(param1);
            this._expandBtn = null;
            this._txtExpandTitle.dispose(param1);
            this._txtExpandTitle = null;
            this._txtUnExpandTitle.dispose(param1);
            this._txtUnExpandTitle = null;
            this._selectBg.dispose();
            this._selectBg = null;
            this._btnImg.dispose();
            this._btnImg = null;
            this._imgName = null;
            return;
        }// end function

    }
}
